import static org.junit.Assert.*;

import org.joda.time.DateTime;
import org.junit.Test;


public class TaskTest {

	@Test
	public void testEqual() {
		DateTime dt = new DateTime(2013,3,26,23,59,0,0);
		Task taskA1 = new Task("Talk to Mary"),
			 taskA2 = new Task("Talk to Mary"),
			 taskB1 = new Task("See John",dt),
			 taskB2 = new Task("See John",dt),
			 taskC1 = new Task("Buy medicines",dt,false),
			 taskC2 = new Task("Buy medicines",dt,true);
		String failureMessage = "isEqual does not work correctly";
		assertTrue(failureMessage,taskA1.isEqual(taskA2));
		assertTrue(failureMessage,taskB1.isEqual(taskB2));
		
		// Two tasks are equal regardless of completion status (so as to undo mark/unmark)
		assertTrue(failureMessage,taskC1.isEqual(taskC2));
		assertFalse(failureMessage,taskA1.isEqual(taskB1));
		
	}
	
	@Test
	public void testCompare() {
		DateTime dt1 = new DateTime(2013,3,26,23,59,0,0),
				 dt2 = new DateTime(2014,3,26,23,59,0,0);
		Task taskA1 = new Task("AAA"),
			 taskA2 = new Task("BBB"),
			 taskB1 = new Task("AAA",dt1),
			 taskB2 = new Task("AAA",dt2),
			 taskC1 = new Task("AAA",dt2),
			 taskC2 = new Task("BBB",dt1);
		String failureMessage = "compareTo does not work correctly";
		assertTrue(failureMessage,taskA1.compareTo(taskA2) < 0);
		assertTrue(failureMessage,taskB1.compareTo(taskB2) < 0);
		assertFalse(failureMessage,taskC1.compareTo(taskC2) < 0);
	}

}
